package com.kylefu.design.pattern.builder;

/**
 * 建造者（Builder）模式：采用链式编程的方式，StringBuilder。
 */
public class Builder2 {

  private Product instance;

  private Builder2() {
    instance = new Product();
  }

  public static Builder2 builder() {
    return new Builder2();
  }

  public Builder2 buildName(String name) {
    instance.setName(name);
    return this;
  }

  public Builder2 buildColor(String color) {
    instance.setColor(color);
    return this;
  }

  public Builder2 buildSize(Integer size) {
    instance.setSize(size);
    return this;
  }

  public Product build() {
    return instance;
  }

}
